package com.atguigu.controller;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @ClassNAME TaskController
 * @Description
 * @Author wuyafeng atguigu
 * @Date 2021/11/11 15:30
 * @Version 1.0
 **/
@Component
public class TaskController {
    /**
     * fixedDelay: 每个多长时间 执行一次任务
     *
     *fixedRate： 整个执行的周期
     */

    @Scheduled(fixedRate = 3000)
    public void myTask() {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(simpleDateFormat.format(new Date()));
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

}
